package cn.zust.ly.entity;


import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Created by liy on 2016/10/12.
 */
@Entity
@Table(name = "tuser")
public class Tuser {

    private int id;
    private String username;
    private String password;
    private String name;
    private String intro;
    private short gender;
    private String province;
    private String city;
    private Date registTime;
    private String type;
    private String email;
    private String mobile;
    private String QQ;
    private short status;

    private Set<Tpicture> pictures = new HashSet<Tpicture>(0);
    private Set<Tconcern> concerners = new HashSet<Tconcern>(0);
    private Set<Tconcern> concerneds = new HashSet<Tconcern>(0);

    public Tuser () {   }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "username")
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "intro")
    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    @Column(name = "gender")
    public short getGender() {
        return gender;
    }

    public void setGender(short gender) {
        this.gender = gender;
    }

    @Column(name = "province")
    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    @Column(name = "city")
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Column(name = "regist_time")
    public Date getRegistTime() {
        return registTime;
    }

    public void setRegistTime(Date registTime) {
        this.registTime = registTime;
    }

    @Column(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Column(name = "QQ")
    public String getQQ() {
        return QQ;
    }

    public void setQQ(String QQ) {
        this.QQ = QQ;
    }

    @Column(name = "status")
    public short getStatus() {
        return status;
    }

    public void setStatus(short status) {
        this.status = status;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
    public Set<Tpicture> getPictures() {
        return pictures;
    }

    public void setPictures(Set<Tpicture> pictures) {
        this.pictures = pictures;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "concerner")
    public Set<Tconcern> getConcerners() {
        return concerners;
    }

    public void setConcerners(Set<Tconcern> concerners) {
        this.concerners = concerners;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "concerned")
    public Set<Tconcern> getConcerneds() {
        return concerneds;
    }

    public void setConcerneds(Set<Tconcern> concerneds) {
        this.concerneds = concerneds;
    }



    public Tuser(String username, String password, String name, String intro, short gender, String province, String city, Date registTime, String type, String email, String mobile, String QQ, short status) {
        this.username = username;
        this.password = password;
        this.name = name;
        this.intro = intro;
        this.gender = gender;
        this.province = province;
        this.city = city;
        this.registTime = registTime;
        this.type = type;
        this.email = email;
        this.mobile = mobile;
        this.QQ = QQ;
        this.status = status;
    }

    @Override
    public String toString() {
        return "Tuser{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", name='" + name + '\'' +
                ", intro='" + intro + '\'' +
                ", gender=" + gender +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", registTime=" + registTime +
                ", type='" + type + '\'' +
                ", email='" + email + '\'' +
                ", mobile='" + mobile + '\'' +
                ", QQ='" + QQ + '\'' +
                ", status=" + status +
                '}';
    }

}
